package dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import pojo.EssayFile;

public interface EssayFileDao {

	//根据essayId查询相关文件
	@Select(value="select * from essayfile where essay_id=#{essayId}")
	@Results({
		@Result(column="file_id",property="fileId",id=true),
		@Result(column="file_path",property="filePath"),
		@Result(column="essay_id",property="essayId"),
		@Result(column="file_label",property="fileLabel"),
		@Result(column="file_name",property="fileName")
	})
	public List<EssayFile> selectByEssayId(Integer essayId);
	
	//根据文章ID删除相关信息
	@Delete(value="delete from essayfile where essay_id=#{essayId}")
	public int deleteByEssayId(Integer essayId);
	
	//找到文章的视频文件
	@Select(value="select * from essayfile where essay_id=#{essayId} and file_label=#{fileLabel}")
	@Results({
		@Result(column="file_id",property="fileId",id=true),
		@Result(column="file_path",property="filePath"),
		@Result(column="essay_id",property="essayId"),
		@Result(column="file_label",property="fileLabel"),
		@Result(column="file_name",property="fileName")
	})
	public List<EssayFile> selectVideo(@Param("essayId")Integer essayId,@Param("fileLabel")String fileLabel);
	
}
